<template>
  <div>
    <input
      type="text"
      placeholder="按回车也可以添加任务哦"
      v-model="value"
      @keyup.enter="enter"
    />
    <button @click="enter">添加</button>
  </div>
</template>

<script lang="ts" setup>
import { ref } from "vue";
const emit = defineEmits(["enter"]);

const value = ref("");
const enter = () => {
  if (value.value === "") {
    alert("不能为空!");
  } else {
    emit("enter", value);
    value.value = "";
  }
};
</script>

<style></style>
